var mongoose  = require('mongoose');
var BaseModel = require("./base_model");
var Schema    = mongoose.Schema;

var DataSourceSchema = new Schema({

    project:{
        type: Schema.Types.ObjectId,
        ref: 'Project'
    },
    DriverType:{
        type:String,
        required: true
    },
    name:{
        type:String,
        required:true
    },
    location:{
        type:String,
        required:true
    },
    user:{
        type:String,
        required:true
    },
    password:{
        type:String,
        required:true
    },
    login_timeout_ms:{
        type:Number,
        required:true
    },
    max_connections:{
        type:Number,
        required:true
    },

    min_connections:{
        type:Number,
        required:true
    },

    idle_life_ms:{
        type:Number,
        required:true
    },
    create_at: { type: Date, default: Date.now },
    update_at: { type: Date, default: Date.now }
});

DataSourceSchema.plugin(BaseModel);
module.exports = mongoose.model('DataSource', DataSourceSchema);